// ----------------------------------------
// Filename: SPI.h
// Description: Routines to implement an MSSP SPI
// Author: Anton Jatmiko
// Date: 22 April 2014

#ifndef SPI_H
#define SPI_H

#include <xc.h>
#include "types.h"

// ----------------------------------------
// SPI_Init
//
// Initialise SPI and its peripheral
// Input:
//   none
// Output:
//   none
// Conditions:
//   none
void SPI_Init(void);

// ----------------------------------------
// SPI_Put
//
// Send data to the slave
// Input:
//   data is the data to be sent
// Output:
//   TRUE if data is sent
// Conditions:
//   assume SPI has been initialised
BOOL SPI_Put(UINT8 data);

// ----------------------------------------
// SPI_Get
//
// Read data from the slave
// Input:
//   dataPtr is a pointer to the data read
// Output:
//   TRUE if data is read
// Conditions:
//   assume SPI has been initialised
BOOL SPI_Get(UINT8 * const dataPtr);

// ----------------------------------------
// SPI_SetInterrupt
//
// Arm or disarm SPI interrupt
// Input:
//   enable is a boolean indicates whether to arm or disarm SPI interrupt
// Output:
//   none
// Conditions:
//   none
void SPI_SetInterrupt(BOOL enable);

#endif